package com.wiwf.model.mapper.config;

import java.sql.SQLException;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.alibaba.druid.pool.DruidDataSource;
import com.wiwf.model.utils.DataSourceUtil;

/**
 * @author kehui
 */
@Configuration(proxyBeanMethods = false)
public class DataSourceAdminBean {

	public static final String NAME = "dataSourceAdmin";
	public static final String PXNAME = DataSourceUtil.PREFIX + ".admin";

	@Bean(NAME)
	DruidDataSource metadataStore(@Value("${" + PXNAME + ".url}") String jdbcUrl,
			@Value("${" + PXNAME + ".driver}") String driver, @Value("${" + PXNAME + ".username}") String username,
			@Value("${" + PXNAME + ".password}") String password) throws SQLException {

		DruidDataSource dataSource = DataSourceUtil.buildDataSource(jdbcUrl, driver, username, password);

		return dataSource;
	}

}